package com.bhs.sansonglogistics.dialog;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bhs.sansonglogistics.R;
import com.bhs.sansonglogistics.utils.SharedPreferencesUtils;
import com.lxj.xpopup.core.AttachPopupView;

/**
 * 评论处理
 */
public class CommentProcessingDialog extends AttachPopupView implements View.OnClickListener {

    private String uid;
    private TextView mTvCopy;
    private TextView mTvDelete;
    private TextView mTvReply;

    public CommentProcessingDialog(@NonNull Context context, String uid) {
        super(context);
        this.uid = uid;
    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.dialog_comment_processing;
    }

    @Override
    protected void onCreate() {
        super.onCreate();
        initView();
        String myUid = SharedPreferencesUtils.getString(getContext(), "uid");
        if (myUid.equals(uid)) {
            mTvReply.setVisibility(GONE);
        } else {
            mTvDelete.setVisibility(GONE);
        }
    }

    private void initView() {
        mTvCopy = findViewById(R.id.tv_copy);
        mTvDelete = findViewById(R.id.tv_delete);
        mTvReply = findViewById(R.id.tv_reply);
        mTvCopy.setOnClickListener(this);
        mTvDelete.setOnClickListener(this);
        mTvReply.setOnClickListener(this);
    }

    private MyClickListener listener;

    public void setMyClickListener(@Nullable MyClickListener l) {
        this.listener = l;
    }

    @Override
    public void onClick(View view) {
        if (listener != null) {
            listener.onClick(view);
        }
    }
}
